<template>
  <div class="p-2">
    <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
      <div class="search" v-show="showSearch">
        <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px" class="search-form">
          <el-form-item label="教职工姓名" prop="realName" label-width="82px">
            <el-input v-model="queryParams.realName" placeholder="请输入教职工姓名" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="联系电话" prop="phone">
            <el-input v-model="queryParams.phone" placeholder="请输入手机号码" clearable style="width: 240px" @keyup.enter="handleQuery" />
          </el-form-item>
          <el-form-item label="职务" prop="postId">
            <el-select v-model="queryParams.postId" placeholder="请选择" clearable>
              <el-option v-for="dict in postOptions" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
            </el-select>
          </el-form-item>
          <!--          <el-form-item label="一卡通号" prop="eCardNo">-->
          <!--            <el-input v-model="queryParams.eCardNo" placeholder="请输入一卡通号" clearable style="width: 240px" @keyup.enter="handleQuery" />-->
          <!--          </el-form-item>-->
          <!--          <el-form-item label="人脸状态">-->
          <!--            <el-select v-model="queryParams.facePicStatus" placeholder="请选择">-->
          <!--              <el-option v-for="dict in face_pic_status" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>-->
          <!--            </el-select>-->
          <!--          </el-form-item>-->
          <el-form-item>
            <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
            <el-button icon="Refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </transition>
    <el-row :gutter="5">
      <!-- 部门树 -->
      <el-col :lg="4" :xs="24">
        <el-card shadow="hover">
          <el-input v-model="deptName" placeholder="请输入部门名称" prefix-icon="Search" clearable />
          <el-tree
            class="mt-2"
            ref="deptTreeRef"
            node-key="id"
            :data="deptOptions"
            :props="{ label: 'label', children: 'children' }"
            :expand-on-click-node="false"
            :filter-node-method="filterNode"
            highlight-current
            default-expand-all
            @node-contextmenu.prevent="openContextMenu"
            @node-click="handleNodeClick"
          />
        </el-card>
      </el-col>
      <el-col :lg="20" :xs="24">
        <el-card shadow="never">
          <template #header>
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" icon="Plus" @click="handleAdd" v-hasPermi="['staff:staffInfo:add']">新增</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['staff:staffInfo:edit']">修改</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['staff:staffInfo:remove']">删除</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button icon="Download" @click="handleExport" v-hasPermi="['staff:staffInfo:export']">导出</el-button>
              </el-col>
              <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
            </el-row>
          </template>

          <el-table
            stripe
            height="calc(100vh - 370px)"
            v-loading="loading"
            :data="staffInfoList"
            @selection-change="handleSelectionChange"
            @row-dblclick="(row: any, column: any, event: Event) => handleUpdate(row)"
          >
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column label="教职工ID" align="center" prop="staffId" v-if="false" />
            <el-table-column label="照片" align="center" prop="facePic" width="100">
              <template #default="scope">
                <image-preview :src="scope.row.facePic" :width="50" :height="50" />
              </template>
            </el-table-column>
            <el-table-column label="教职工姓名" align="center" prop="realName" />
            <el-table-column label="性别" align="center" prop="sex">
              <template #default="scope">
                <dict-tag :options="sys_user_sex" :value="scope.row.sex" />
              </template>
            </el-table-column>
            <el-table-column label="联系电话" align="center" prop="phone" />
            <!--            <el-table-column label="一卡通号" align="center" prop="eCardNo" />-->
            <el-table-column label="身份证号" align="center" prop="idCardNo" />
            <el-table-column label="职务" align="center" prop="postIds">
              <template #default="scope">
                <dict-tag :options="postOptions" :value="scope.row.postIds" />
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
              <template #default="scope">
                <el-tooltip content="修改" placement="top">
                  <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['staff:staffInfo:edit']"></el-button>
                </el-tooltip>
                <el-tooltip content="删除" placement="top">
                  <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['staff:staffInfo:remove']"></el-button>
                </el-tooltip>
              </template>
            </el-table-column>
          </el-table>

          <pagination v-show="total>0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
        </el-card>
      </el-col>
    </el-row>
    <div v-show="showMenu" class="custom-menu">
      <ul>
        <li @click="menuItemAdd">添加子部门</li>
        <li @click="menuItemUpdate">编辑</li>
        <li @click="menuItemDelete" v-show="!currentNodeData.children">删除</li>
        <li @click="menuHide">取消</li>
      </ul>
    </div>
    <!-- 添加或修改教职工信息对话框 -->
    <el-dialog :title="dialog.title" v-model="dialog.visible" width="900px" append-to-body>
      <el-form ref="staffInfoFormRef" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="4">
            照片
            <image-upload v-model="form.facePic" :isShowTip="false" :limit="1" :verifyWay="1" />
          </el-col>
          <el-col :span="18">
            <el-row>
              <el-col :span="8">
                <el-form-item label="姓名" prop="realName">
                  <el-input v-model="form.realName" placeholder="请输入姓名" clearable/>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="性别" prop="sex">
                  <el-select v-model="form.sex" placeholder="请选择" clearable>
                    <el-option v-for="dict in sys_user_sex" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="联系电话" prop="phone" >
                  <el-input v-model="form.phone" placeholder="请输入联系电话" clearable/>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="身份证号" prop="idCardNo">
                  <el-input v-model="form.idCardNo" placeholder="请输入身份证号" @change="setBirthdayByIdCard" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="出生日期" prop="birthday">
                  <el-date-picker clearable v-model="form.birthday" type="date" value-format="YYYYMMDD" format="YYYY-MM-DD" placeholder="出生日期"
                                  :disabled-date="(date) => date.getTime() > Date.now()"/>
                </el-form-item>
              </el-col>
              <!--              <el-col :span="8">-->
              <!--                <el-form-item label="一卡通号" prop="eCardNo">-->
              <!--                  <el-input v-model="form.eCardNo" placeholder="请输入一卡通号" />-->
              <!--                </el-form-item>-->
              <!--              </el-col>-->
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="职务" prop="postIds">
                  <el-select v-model="form.postIds" multiple placeholder="请选择">
                    <el-option
                      v-for="item in postOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                      :disabled="item.status == '1'"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="部门" prop="deptId" required>
                  <el-tree-select
                    v-model="form.deptId"
                    :data="deptOptions"
                    :props="{ value: 'id', label: 'label', children: 'children' }"
                    value-key="deptId"
                    placeholder="请选择部门"
                    check-strictly
                    default-expand-all
                  />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="户籍" prop="censusRegister">
                  <el-input v-model="form.censusRegister" placeholder="请输入户籍" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="住址" prop="address">
                  <el-input v-model="form.address" placeholder="请输入住址" />
                </el-form-item>
              </el-col>
            </el-row>

            <el-row v-for="(item, index) in form.classes">
              <el-col :span="8">
                <el-form-item
                  label="关联班级"
                  :prop="'classes.' + index + '.classId'"
                  :rules="{ required: true, message: '关联班级不能为空', trigger: 'blur' }"
                >
                  <el-tree-select
                    v-model="item.classId"
                    :data="classOptions"
                    :props="{ value: 'id', label: 'label', children: 'children' }"
                    value-key="classId"
                    placeholder="请选择班级"
                    check-strictly
                    default-expand-all
                  />
                </el-form-item>
              </el-col>
              <el-col :span="7">
                <el-form-item
                  label="角色"
                  :prop="'classes.' + index + '.roleId'"
                  :rules="{ required: true, message: '关联班级角色不能为空', trigger: 'change' }"
                >
                  <el-select v-model="item.roleId" placeholder="请选择">
                    <el-option v-for="dict in school_class_role" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="7">
                <el-form-item
                  label="科目"
                  :prop="'classes.' + index + '.subjectId'"
                  :rules="{ required: true, message: '关联班级科目不能为空', trigger: 'change' }"
                >
                  <el-select v-model="item.subjectId" placeholder="请选择" style="width: 120px">
                    <el-option v-for="dict in school_subject" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="2">
                <el-button type="danger" plain icon="Delete" @click="removeClass(item)"></el-button>
              </el-col>
            </el-row>
            <el-form-item>
              <el-button plain icon="Plus" @click="addClass">新增班级</el-button>
            </el-form-item>
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <el-dialog :title="deptDialog.title" v-model="deptDialog.visible" destroy-on-close append-to-body width="600px">
      <el-form ref="deptFormRef" :model="deptForm" label-width="80px">
        <el-row>
          <el-col :span="24" v-if="deptForm.parentId !== 0">
            <el-form-item label="上级部门" prop="parentId">
              <el-tree-select
                v-model="deptForm.parentId"
                :data="parentDeptOptions"
                :props="{ value: 'deptId', label: 'deptName', children: 'children' }"
                value-key="deptId"
                placeholder="选择上级部门"
                check-strictly
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="部门名称" prop="deptName" :rules="{ required: true, message: '部门名称不能为空', trigger: 'blur' }">
              <el-input v-model="deptForm.deptName" placeholder="请输入部门名称" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitDeptForm">确 定</el-button>
          <el-button @click="cancelDeptForm">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="StaffInfo" lang="ts">
import api from '@/api/system/user';
import { addStaff, delStaff, getStaff, listStaff, updateStaff } from '@/api/office/staff';
import { StaffForm, StaffQuery, StaffVO } from '@/api/office/staff/types';
import { DeptForm, DeptVO } from '@/api/system/dept/types';
import { addDept, delDept, getDept, listDept, listDeptExcludeChild, updateDept } from '@/api/system/dept';
import { uuid } from '@/utils/ruoyi';
import { classTree, listClassInfo } from '@/api/office/class';
import { PostVO } from '@/api/system/post/types';
import { dictPost } from "@/api/system/post";

const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { face_pic_status, sys_user_sex, school_subject, school_class_role } = toRefs<any>(
  proxy?.useDict('face_pic_status', 'sys_user_sex', 'school_subject', 'school_class_role')
);

const staffInfoList = ref<StaffVO[]>([]);
const buttonLoading = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref<Array<string | number>>([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const classOptions = ref<any[]>([]);
const deptName = ref('');
const deptOptions = ref<DeptVO[]>([]);
const queryFormRef = ref<ElFormInstance>();
const staffInfoFormRef = ref<ElFormInstance>();
const deptTreeRef = ref<ElTreeInstance>();
const postOptions = ref<any[]>([]);
const dialog = reactive<DialogOption>({
  visible: false,
  title: ''
});
const idCardNoValidator = (rule, value, callback) => {
  const reg = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/;
  if (value && !reg.test(value)) {
    callback(new Error('请输入正确的身份证号'));
  } else {
    callback();
  }
};

const phoneValidator = (rule, value, callback) => {
  const reg = /^1[3-9]\d{9}$/;
  if (!value) {
    callback(new Error('联系人电话不能为空'));
  } else if (!reg.test(value)) {
    callback(new Error('请输入正确的手机号'));
  } else {
    callback();
  }
};

const initFormData: StaffForm = {
  deptId: undefined,
  realName: undefined,
  phone: undefined,
  birthday: undefined,
  eCardNo: undefined,
  idCardNo: undefined,
  censusRegister: undefined,
  address: undefined,
  sex: undefined,
  facePic: undefined,
  facePicStatus: undefined,
  postIds: [],
  classes: [],
  remark: undefined
};
const data = reactive<PageData<StaffForm, StaffQuery>>({
  form: { ...initFormData },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    deptId: undefined,
    realName: undefined,
    postId: undefined,
    phone: undefined,
    birthday: undefined,
    eCardNo: undefined,
    idCardNo: undefined,
    censusRegister: undefined,
    address: undefined,
    facePicStatus: undefined,
    params: {}
  },
  rules: {
    deptId: [{ required: true, message: '部门不能为空', trigger: 'change' }],
    realName: [{ required: true, message: '教职工姓名不能为空', trigger: 'blur' }],
    email: [{ required: true, message: '用户邮箱不能为空', trigger: 'blur' }],
    phone: [{ required: true, validator: phoneValidator, trigger: 'blur' }],
    idCardNo: [{ validator: idCardNoValidator, trigger: 'blur' }],
    postIds: [{ required: true, message: '职务不能为空', trigger: 'change' }],
    address: [{ message: '住址不能为空', trigger: 'blur' }],
    sex: [{ required: true, message: '用户性别不能为空', trigger: 'change' }],
    facePicStatus: [{ required: true, message: '人脸状态不能为空', trigger: 'change' }],
    password: [{ required: true, message: '密码不能为空', trigger: 'blur' }],
    status: [{ required: true, message: '帐号状态不能为空', trigger: 'change' }],
    loginIp: [{ required: true, message: '最后登录IP不能为空', trigger: 'blur' }],
    loginDate: [{ required: true, message: '最后登录时间不能为空', trigger: 'blur' }]
  }
});

const { queryParams, form, rules } = toRefs(data);

const deptDialog = reactive<DialogOption>({
  visible: false,
  title: ''
});

const deptFormRef = ref<ElFormInstance>();
const parentDeptOptions = ref<DeptVO[]>([]);
const initDeptForm: DeptForm = {
  deptId: undefined,
  parentId: undefined,
  deptName: undefined,
  orderNum: 0,
  leader: undefined,
  phone: undefined,
  email: undefined,
  status: '0'
};

const deptForm = ref({ ...initDeptForm });
/** 通过条件过滤节点  */
const filterNode = (value: string, data: any) => {
  if (!value) return true;
  return data.label.indexOf(value) !== -1;
};

/** 根据名称筛选部门树 */
watchEffect(
  () => {
    deptTreeRef.value?.filter(deptName.value);
  },
  {
    flush: 'post' // watchEffect会在DOM挂载或者更新之前就会触发，此属性控制在DOM元素更新后运行
  }
);

/** 查询部门下拉树结构 */
const getTreeSelect = async () => {
  const res = await api.deptTreeSelect();
  // deptOptions.value = res.data;
  deptOptions.value = res.data[0].children;
};

const getClassTree = async () => {
  const res = await classTree();
  classOptions.value = res.data;
};


const loadPosts = async () => {
  const res = await dictPost();
  postOptions.value = res.data;
}

/** 节点单击事件 */
const handleNodeClick = (data: DeptVO) => {
  queryParams.value.deptId = data.id;
  handleQuery();
};

/** 查询教职工信息列表 */
const getList = async () => {
  await loadPosts();
  loading.value = true;
  const res = await listStaff(queryParams.value);
  staffInfoList.value = res.rows;
  total.value = res.total;
  loading.value = false;
};

const setBirthdayByIdCard = () => {
  // 身份证上出生日期的位置为6至14
  form.value.birthday = form.value.idCardNo?.substring(6, 14);
};

/** 取消按钮 */
const cancel = () => {
  reset();
  dialog.visible = false;
};

/** 表单重置 */
const reset = () => {
  form.value = { ...initFormData };
  form.value.postIds = [];
  form.value.classes = [];
  staffInfoFormRef.value?.resetFields();
};

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.value.pageNum = 1;
  getList();
};

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value?.resetFields();
  handleQuery();
};

/** 多选框选中数据 */
const handleSelectionChange = (selection: StaffVO[]) => {
  ids.value = selection.map((item) => item.staffId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
};

/** 新增按钮操作 */
const handleAdd = async () => {
  reset();
  await getClassTree();
  addClass();
  dialog.visible = true;
  dialog.title = '新增教职工';
};

/** 修改按钮操作 */
const handleUpdate = async (row?: StaffVO) => {
  reset();
  await getClassTree();
  const _staffId = row?.staffId || ids.value[0];
  const res = await getStaff(_staffId);
  Object.assign(form.value, res.data);
  if (!form.value.birthday) {
    setBirthdayByIdCard();
  }
  dialog.visible = true;
  dialog.title = '修改教职工信息';
};

/** 提交按钮 */
const submitForm = () => {
  staffInfoFormRef.value?.validate(async (valid: boolean) => {
    if (valid) {
      buttonLoading.value = true;
      if (form.value.staffId) {
        await updateStaff(form.value).finally(() => (buttonLoading.value = false));
        proxy?.$modal.msgSuccess('修改成功');
      } else {
        await addStaff(form.value).finally(() => (buttonLoading.value = false));
        proxy?.$modal.msgSuccess('新增成功');
      }
      dialog.visible = false;
      await getList();
    }
  });
};

/** 删除按钮操作 */
const handleDelete = async (row?: StaffVO) => {
  const _staffIds = row ? [row.staffId] : ids.value;
  let msg = staffInfoList.value
    .filter((e) => _staffIds.find((id) => e.staffId === id))
    .map((e) => e.realName)
    .join(',');
  await proxy?.$modal.confirm('是否确认删除教职工姓名为"' + msg + '"的数据项？').finally(() => (loading.value = false));
  await delStaff(_staffIds);
  proxy?.$modal.msgSuccess('删除成功');
  await getList();
};

/** 导出按钮操作 */
const handleExport = () => {
  proxy?.download(
    'office/staff/export',
    {
      ...queryParams.value
    },
    `staffInfo_${new Date().getTime()}.xlsx`
  );
};
const showMenu = ref(false);
const currentNodeData = ref<any>({});
const openContextMenu = (event: any, nodeData: any) => {
  // 设置菜单的位置
  const menu = proxy?.$el.querySelector('.custom-menu');
  const clickX = event.clientX;
  const clickY = event.clientY;
  menu.style.left = clickX + 10 + 'px';
  menu.style.top = clickY + 'px';
  currentNodeData.value = nodeData;
  showMenu.value = true;
};

const menuItemAdd = (option: any) => {
  showMenu.value = false;
  handleDeptAdd(currentNodeData.value);
};

const menuItemUpdate = (option: any) => {
  showMenu.value = false;
  handleDeptUpdate(currentNodeData.value);
};

const menuItemDelete = async () => {
  showMenu.value = false;
  await handleDeleteDept(currentNodeData.value);
};

const menuHide = (option: any) => {
  showMenu.value = false;
};

interface DeptOptionsType {
  deptId: number | string;
  deptName: string;
  children: DeptOptionsType[];
}

const handleDeptAdd = async (row?: DeptVO) => {
  resetDeptForm();
  const res = await listDept();
  const data = proxy?.handleTree<DeptOptionsType>(res.data, 'deptId');
  if (data) {
    parentDeptOptions.value = data;
    if (row && row.id) {
      deptForm.value.parentId = row?.id;
    }
    deptDialog.visible = true;
    deptDialog.title = '添加部门';
  }
};

/** 修改按钮操作 */
const handleDeptUpdate = async (row: DeptVO) => {
  resetDeptForm();
  //查询当前部门所有用户
  // getDeptAllUser(row.deptId);
  const res = await getDept(row.id);
  deptForm.value = res.data;
  const response = await listDeptExcludeChild(row.id);
  const data = proxy?.handleTree<DeptOptionsType>(response.data, 'deptId');
  if (data) {
    parentDeptOptions.value = data;
    if (data.length === 0) {
      const noResultsOptions: DeptOptionsType = {
        deptId: res.data.parentId,
        deptName: res.data.parentName,
        children: []
      };
      parentDeptOptions.value.push(noResultsOptions);
    }
  }
  deptDialog.visible = true;
  deptDialog.title = '修改部门';
};

/** 提交按钮 */
const submitDeptForm = () => {
  deptFormRef.value?.validate(async (valid: boolean) => {
    if (valid) {
      deptForm.value.deptId ? await updateDept(deptForm.value) : await addDept(deptForm.value);
      proxy?.$modal.msgSuccess('操作成功');
      deptDialog.visible = false;
      await getTreeSelect();
    }
  });
};

const resetDeptForm = () => {
  deptForm.value = { ...initDeptForm };
  deptFormRef.value?.resetFields();
};

/** 取消按钮 */
const cancelDeptForm = () => {
  resetDeptForm();
  deptDialog.visible = false;
};

/** 删除按钮操作 */
const handleDeleteDept = async (row: DeptVO) => {
  await proxy?.$modal.confirm('是否确认删除名称为"' + row.label + '"的数据项?');
  await delDept(row.id);
  await getTreeSelect();
  proxy?.$modal.msgSuccess('删除成功');
};

const searchClassInfo = (queryString, cb) => {
  listClassInfo({ className: queryString }).then((response) => {
    cb(response.rows);
  });
};

const addClass = () => {
  form.value.classes.push({ idx: uuid(), staffId: undefined, postId: undefined });
};

const removeClass = (item: any) => {
  form.value.classes = form.value.classes.filter((e) => e.idx !== item.idx);
};

onMounted(() => {
  getTreeSelect(); // 初始化部门数据
  getList();
});
</script>
<style lang="scss" scoped>
@import '@/assets/styles/variables.module.scss';
.custom-menu {
  position: fixed;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  z-index: 1000;
}

.custom-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.custom-menu ul li {
  padding: 8px 20px;
  cursor: pointer;
  font-size: 13px;
  color: $blue;
}

.custom-menu ul li:hover {
  background-color: #eee;
}
.ss-tabs {
  background-color: #fff;
}
</style>
